//
// Copyright (c) Microsoft Corporation.  All rights reserved.
//
//
// Use of this sample source code is subject to the terms of the Microsoft
// license agreement under which you licensed this sample source code. If
// you did not accept the terms of the license agreement, you are not
// authorized to use this sample source code. For the terms of the license,
// please see the license agreement between you and Microsoft or, if applicable,
// see the LICENSE.RTF on your install media or the root of your tools installation.
// THE SAMPLE SOURCE CODE IS PROVIDED "AS IS", WITH NO WARRANTIES OR INDEMNITIES.
//
//////////////////////////////////////////////////////////////////////////////
// Copyright (C) 2003 Intrinsyc Europe Ltd.
//////////////////////////////////////////////////////////////////////////////
// Copyright (C) 2004 Siemens AG
//
// Version: 1.1.2.5
// Date:    11. Jan. 2006
//////////////////////////////////////////////////////////////////////////////


#pragma once

#define SUPSVC_CMDBUF_LENGTH        (MAX_ATCMD_LEN)
// We do not need this calculation: any string from or to the AT interface will not exceed MAX_ATCMD_LEN character
//#define SUPSVC_CMDBUF_LENGTH        (MAX_PATH + MAXLENGTH_ADDRESS)
#define SUPSVC_ALLOC_NUMBER         16         // Max. numbers of digits for call forwaring numbers

#define USSD_TIMEOUT                30000      // Timeout: Response for USSD commands (in ms)

//
// Information classes
//
const DWORD g_rgdwInfoClasses[] =
{
    RIL_INFOCLASS_VOICE,            // 1  = 2^0
    RIL_INFOCLASS_DATA,             // 2  = 2^1
    RIL_INFOCLASS_FAX,              // 4  = 2^2
    RIL_INFOCLASS_SMS,              // 8  = 2^3
    RIL_INFOCLASS_DATACIRCUITSYNC,  // 16 = 2^4
    RIL_INFOCLASS_DATACIRCUITASYNC, // 32 = 2^5
    RIL_INFOCLASS_PACKETACCESS,     // 32 = 2^6
    RIL_INFOCLASS_PADACCESS,        // 64 = 2^7
};
#define NUM_INFOCLASSES        (sizeof(g_rgdwInfoClasses) / sizeof(DWORD))

//
// Translation table InfoClass -> BS
//
struct INFOCLASS2BS
{
    DWORD dwInfoClass;
    UINT  uiBS;
};

static const INFOCLASS2BS g_rgInfoClassTable[] =
{
    {RIL_INFOCLASS_VOICE, 11},
    {RIL_INFOCLASS_FAX, 13},
    {RIL_INFOCLASS_SMS, 16},
    {RIL_INFOCLASS_FAX|RIL_INFOCLASS_SMS, 12},
    {RIL_INFOCLASS_DATACIRCUITASYNC, 25},
    {RIL_INFOCLASS_DATACIRCUITSYNC, 24},
    {RIL_INFOCLASS_PADACCESS, 27},
    {RIL_INFOCLASS_PACKETACCESS, 26},
    {RIL_INFOCLASS_DATACIRCUITASYNC|RIL_INFOCLASS_PADACCESS, 21},
    {RIL_INFOCLASS_DATACIRCUITSYNC|RIL_INFOCLASS_PACKETACCESS, 22},
    {RIL_INFOCLASS_DATACIRCUITASYNC|RIL_INFOCLASS_DATACIRCUITSYNC|RIL_INFOCLASS_PACKETACCESS|RIL_INFOCLASS_PADACCESS, 20},
    {RIL_INFOCLASS_DATA, 20},
    {RIL_INFOCLASS_VOICE|RIL_INFOCLASS_DATA|RIL_INFOCLASS_FAX|RIL_INFOCLASS_SMS, 100},     // 100 -> ommit parameter
    {RIL_INFOCLASS_VOICE|RIL_INFOCLASS_DATA|RIL_INFOCLASS_FAX, 100}     // this is not conform to spec but occasional MS uses this combination, when the mean all services.
};
#define NUM_BS_VALUES    (sizeof(g_rgInfoClassTable) / sizeof(INFOCLASS2BS))

//
// Translation table Forwarding Type -> *#-Code
//
#define RIL_FORWARDINGSTATUS_ACTIVATE                (0x00000001)
#define RIL_FORWARDINGSTATUS_DEACTIVATE              (0x00000002)
#define RIL_FORWARDINGSTATUS_QUERY                   (0x00000003)
#define RIL_FORWARDINGSTATUS_REGISTER                (0x00000004)
#define RIL_FORWARDINGSTATUS_REMOVE                  (0x00000005)

struct FORWARDING2ATD
{
    DWORD dwForwardingReason;
    DWORD dwForwardingStatus;
    char  szATD[8];
    BOOL  bNeedsT;
};

static const FORWARDING2ATD g_rgForwardingTypeTable[] =
{
    {RIL_FWDREASON_UNCONDITIONAL, RIL_FORWARDINGSTATUS_ACTIVATE, "*21", FALSE},
    {RIL_FWDREASON_MOBILEBUSY,    RIL_FORWARDINGSTATUS_ACTIVATE, "*67", FALSE},
    {RIL_FWDREASON_NOREPLY,       RIL_FORWARDINGSTATUS_ACTIVATE, "*61", TRUE},
    {RIL_FWDREASON_UNREACHABLE,   RIL_FORWARDINGSTATUS_ACTIVATE, "*62", FALSE},
    {RIL_FWDREASON_ALLFORWARDING, RIL_FORWARDINGSTATUS_ACTIVATE, "*002", TRUE},
    {RIL_FWDREASON_ALLCONDITIONAL,RIL_FORWARDINGSTATUS_ACTIVATE, "*004", TRUE},
    {RIL_FWDREASON_UNCONDITIONAL, RIL_FORWARDINGSTATUS_DEACTIVATE, "#21", FALSE},
    {RIL_FWDREASON_MOBILEBUSY,    RIL_FORWARDINGSTATUS_DEACTIVATE, "#67", FALSE},
    {RIL_FWDREASON_NOREPLY,       RIL_FORWARDINGSTATUS_DEACTIVATE, "#61", TRUE},
    {RIL_FWDREASON_UNREACHABLE,   RIL_FORWARDINGSTATUS_DEACTIVATE, "#62", FALSE},
    {RIL_FWDREASON_ALLFORWARDING, RIL_FORWARDINGSTATUS_DEACTIVATE, "#002", TRUE},
    {RIL_FWDREASON_ALLCONDITIONAL,RIL_FORWARDINGSTATUS_DEACTIVATE, "#004", TRUE},
    {RIL_FWDREASON_UNCONDITIONAL, RIL_FORWARDINGSTATUS_QUERY, "*#21", FALSE},
    {RIL_FWDREASON_MOBILEBUSY,    RIL_FORWARDINGSTATUS_QUERY, "*#67", FALSE},
    {RIL_FWDREASON_NOREPLY,       RIL_FORWARDINGSTATUS_QUERY, "*#61", TRUE},
    {RIL_FWDREASON_UNREACHABLE,   RIL_FORWARDINGSTATUS_QUERY, "*#62", FALSE},
    {RIL_FWDREASON_ALLFORWARDING, RIL_FORWARDINGSTATUS_QUERY, "*#002", TRUE},
    {RIL_FWDREASON_ALLCONDITIONAL,RIL_FORWARDINGSTATUS_QUERY, "*#004", TRUE},
    {RIL_FWDREASON_UNCONDITIONAL, RIL_FORWARDINGSTATUS_REGISTER, "**21", FALSE},
    {RIL_FWDREASON_MOBILEBUSY,    RIL_FORWARDINGSTATUS_REGISTER, "**67", FALSE},
    {RIL_FWDREASON_NOREPLY,       RIL_FORWARDINGSTATUS_REGISTER, "**61", TRUE},
    {RIL_FWDREASON_UNREACHABLE,   RIL_FORWARDINGSTATUS_REGISTER, "**62", FALSE},
    {RIL_FWDREASON_ALLFORWARDING, RIL_FORWARDINGSTATUS_REGISTER, "**002", TRUE},
    {RIL_FWDREASON_ALLCONDITIONAL,RIL_FORWARDINGSTATUS_REGISTER, "**004", TRUE},
    {RIL_FWDREASON_UNCONDITIONAL, RIL_FORWARDINGSTATUS_REMOVE, "##21", FALSE},
    {RIL_FWDREASON_MOBILEBUSY,    RIL_FORWARDINGSTATUS_REMOVE, "##67", FALSE},
    {RIL_FWDREASON_NOREPLY,       RIL_FORWARDINGSTATUS_REMOVE, "##61", TRUE},
    {RIL_FWDREASON_UNREACHABLE,   RIL_FORWARDINGSTATUS_REMOVE, "##62", FALSE},
    {RIL_FWDREASON_ALLFORWARDING, RIL_FORWARDINGSTATUS_REMOVE, "##002", TRUE},
    {RIL_FWDREASON_ALLCONDITIONAL,RIL_FORWARDINGSTATUS_REMOVE, "##004", TRUE}
};
#define NUM_FORWARDING_VALUES    (sizeof(g_rgForwardingTypeTable) / sizeof(FORWARDING2ATD))

//
// Translation table Call Waiting Type -> *#-Code
//
#define RIL_CALLWAITINGSTATUS_ACTIVATE                (0x00000001)
#define RIL_CALLWAITINGSTATUS_DEACTIVATE              (0x00000002)
#define RIL_CALLWAITINGSTATUS_QUERY                   (0x00000003)

struct CALLWAITING2ATD
{
    DWORD dwCallWaitingStatus;
    char  szATD[8];
};

static const CALLWAITING2ATD g_rgCallWaitingTypeTable[] =
{
    {RIL_CALLWAITINGSTATUS_ACTIVATE, "*43" },
    {RIL_CALLWAITINGSTATUS_DEACTIVATE, "#43" },
    {RIL_CALLWAITINGSTATUS_QUERY, "*#43" }
};
#define NUM_CALLWAITING_VALUES    (sizeof(g_rgCallWaitingTypeTable) / sizeof(CALLWAITING2ATD))

// This #define is missing on some Microsoft builds.
#ifndef RIL_INFOCLASS_NONE
#define RIL_INFOCLASS_NONE    (0x00000000)      
#endif
// These default values are used, when RIL_INFOCLASS_NONE is passed by the MMI.
#define RIL_INFOCLASS_DEFAULT_CALLWAITING   (RIL_INFOCLASS_VOICE | RIL_INFOCLASS_DATA | RIL_INFOCLASS_FAX)
#define RIL_INFOCLASS_DEFAULT_CALLFORWARING (RIL_INFOCLASS_VOICE | RIL_INFOCLASS_DATA | RIL_INFOCLASS_FAX)
#define RIL_INFOCLASS_DEFAULT_CALLBARRING   (RIL_INFOCLASS_VOICE | RIL_INFOCLASS_DATA | RIL_INFOCLASS_FAX | RIL_INFOCLASS_SMS)

//
// Translation function InfoClass (Microsoft) -> BS (GSM)
//
UINT RILDrv_FindBS4InfoClass(DWORD dwInfoClass);

HRESULT RILDrv_GetCallerIdSettings(DWORD dwParam);
HRESULT RILDrv_SetCallerIdStatus(DWORD dwParam, DWORD dwStatus);
HRESULT RILDrv_GetHideIdSettings(DWORD dwParam);
HRESULT RILDrv_SetHideIdStatus(DWORD dwParam, DWORD dwStatus);
HRESULT RILDrv_GetDialedIdSettings(DWORD dwParam);
HRESULT RILDrv_SetDialedIdStatus(DWORD dwParam, DWORD dwStatus);
HRESULT RILDrv_GetHideConnectedIdSettings(DWORD dwParam);
HRESULT RILDrv_GetClosedGroupSettings(DWORD dwParam);
HRESULT RILDrv_SetClosedGroupSettings(DWORD dwParam, const RILCLOSEDGROUPSETTINGS* lpSettings);
HRESULT RILDrv_GetCallForwardingSettings(DWORD dwParam, DWORD dwReason, DWORD dwInfoClasses);
HRESULT RILDrv_AddCallForwarding(DWORD dwParam, DWORD dwReason, const RILCALLFORWARDINGSETTINGS* lpSettings);
HRESULT RILDrv_RemoveCallForwarding(DWORD dwParam, DWORD dwReason, DWORD dwInfoClasses);
HRESULT RILDrv_SetCallForwardingStatus(DWORD dwParam, DWORD dwReason, DWORD dwInfoClasses, DWORD dwStatus);
HRESULT RILDrv_GetCallWaitingSettings(DWORD dwParam, DWORD dwInfoClasses);
HRESULT RILDrv_SetCallWaitingStatus(DWORD dwParam, DWORD dwInfoClasses, DWORD dwStatus);
HRESULT RILDrv_SendSupServiceData(DWORD dwParam, const BYTE* lpbData, DWORD dwSize);
HRESULT RILDrv_CancelSupServiceDataSession(DWORD dwParam);



